/********************************************************************
 *@brief Define notification system
 *@author wcf
 *@date 2025-01-11
********************************************************************/

#ifndef __CS_NOTIFY_H__
#define __CS_NOTIFY_H__

#include "cscoreglobal.h"

CS_NAMESPACE_BEGIN

#define CS_NOTIFY_BEGIN(Class) Class##Begin
#define CS_NOTIFY_END(Class) Class##End
#define CS_NOTIFY_BEGIN_DECL(Class, SuperClass) CS_NOTIFY_BEGIN(Class) = CS_NOTIFY_BEGIN(SuperClass)
#define CS_NOTIFY_END_DECL(Class) CS_NOTIFY_END(Class)

#define CS_NOTIFY_VOLID_DECL(Class)\
    virtual bool isValidNotifySelf(const NotifyType& type) const\
    {\
        return type >= CS_NOTIFY_BEGIN(Class) && type < CS_NOTIFY_END(Class);\
    }\
    virtual bool isValidNotify(const NotifyType& type) const\
    {\
        return type >= CS_NOTIFY_BEGIN(csObject) && type < CS_NOTIFY_END(Class);\
    }

class csObject;
class CSCORE_EXPORT csNotify
{
public:
    csNotify(int type, csObject* pSender);
    virtual ~csNotify();
    int type() const;
    csObject* sender() const;
private:
    int m_type = -1;
    csObject* m_pSender = nullptr;
};

CS_NAMESPACE_END

#endif // !__CS_NOTIFY_H__
